<?php
/* @var $this PenerimaanTamuController */
/* @var $model PenerimaanTamu */

$this->breadcrumbs=array(
	'Penerimaan Tamu'=>array('index'),
	'Pendaftaran',
);

?>

<?php $this->beginWidget('ext.widgets.XPanel', array('width'=>900, 'height'=>130, 'title'=> 'Penerimaan Tamu')); ?>

<!-- form start -->
<div class="form">
	<?php 
        
        $js = <<< EOF_JS
function beforeValidate(form) {
    
    var identitas= $('.items tbody tr').size();
    
    if(identitas<=0){
        alert('Identitas masih kosong');
        return false;
    }

    if($('#Tamu_foto').val()!='')
    {
        return true;
    }else{
        alert('Foto belum di capture');
        return false;
    }
 
}
EOF_JS;
Yii::app()->clientScript->registerScript('penerimaan-tamu-form-beforeValidate', $js);

        $form = $this->beginWidget('CActiveForm', 
                array(
                    'id' => 'penerimaan-tamu-form',
                    'enableAjaxValidation'=>true,
                    'enableClientValidation'=>true,
                    'clientOptions'=>array(
                            'validateOnSubmit'=>true,
                            'beforeValidate' => 'js:beforeValidate'
                    ),
                    'htmlOptions'=>array(
                               'onsubmit'=>"",/* Disable normal form submit */
                               'onkeypress'=>"" /* Do ajax call when user presses enter key */
                             )
                    )
                );?>
	<fieldset>
		<legend>Data Tamu</legend>
                <table>
                    <tr>
                        <td style="vertical-align: top">
                            
                            <fieldset>
                                <legend>Identitas</legend>
                                <table>
                                
                                    <tr>
                                        <td width="150"><?php echo CHtml::label('No Identitas', 'no_identitas')?> : </td>
                                        <td width="500">
                                                <?php 
                                                
                                                $this->beginWidget('zii.widgets.jui.CJuiDialog', array(
                                                    'id'=>'TamuConfirmDialog',
                                                    // additional javascript options for the dialog plugin
                                                    'options'=>array(
                                                        'title'=>'Konfirmasi',
                                                        'width' => 300,
                                                        'height' => 300,
                                                        'buttons' => array(
                                                            'Bukan' => 'js:function() {
                                                                        $( this ).dialog( "close" );
                                                                        return false;
                                                                    }',
                                                            'Ya' => 'js:function() {
                                                                        $( this ).dialog( "close" );
                                                                        $("#no_identitas").val("");
                                                                        $("#tipe_identitas").val("");
                                                                        
                                                                        auto_tamu(dataTamu);
                                                                    }'
                                                        ),
                                                        'autoOpen'=>false,
                                                    ),
                                                ));
                                                 ?>
                                                 Apakah Data yang dimaksud adalah : 
                                                <div id="dialogContent">
                                                    <table width="20%">
                                                        <tr>
                                                            <td>Nama :</td>
                                                            <td id="dialogNama"></td>
                                                        </tr>
                                                        <tr>
                                                            <td>Instansi : </td>
                                                            <td id="dialogInstansi"></td>
                                                        </tr>
                                                    </table>
                                                    <div id="dialogFoto"></div>
                                                </div>
                                                <?php
                                                $this->endWidget('zii.widgets.jui.CJuiDialog');
                                                
                                                
                                                Yii::app()->getClientScript()->registerScript(
                                                        'condirmation',
                                                        "",
                                                        CClientScript::POS_END);
                                                
                                                
                                                    Yii::app()->getClientScript()->registerScript(
                                                            'autotamu', 
                                                            "
                                                                var dataTamu = null;
                                                                
                                                                function confirm_tamu(ui){
                                                                    $('#dialogNama').html(ui.item.nama_tamu);
                                                                    $('#dialogInstansi').html(ui.item.instansi);
                                                                    
                                                                    var foto = '<img width=150 src=/images/photos/'+ui.item.foto+' />';
                                                                    $('#dialogFoto').html(foto);
                                                                    
                                                                    $('#TamuConfirmDialog').dialog('open');
                                                                }

                                                                function auto_tamu(ui){
                                                                    $('#Tamu_foto').val('false');
                                                                    $('#Tamu_id_tamu').val(ui.item.id_tamu);
                                                                    $('#Tamu_nama').val(ui.item.nama_tamu);
                                                                    $('#Tamu_no_hp').val(ui.item.no_hp);
                                                                    $('#Instansi_nama').val(ui.item.instansi);
                                                                    $('#Instansi_id_instansi').val(ui.item.id_instansi);
                                                                    
                                                                    var foto = '<img src=/images/photos/'+ui.item.foto+' />';
                                                                    $('#capture').html(foto);
                                                                    
                                                                    $('#camera').hide();
                                                                    $('#capture').show();
                                                                    
                                                                    $('#photoSnap').hide();
                                                                    $('#photoReset').show();

                                                                    $.ajax({
                                                                        url : '".Yii::app()->createUrl('identitas/autocomplete', array('by'=>'id_tamu', 'comparison'=> '=', 'term'=>NULL))."'+ui.item.id_tamu,
                                                                        dataType : 'json',
                                                                        success : function(data){

                                                                            $('.items tbody').html('');
                                                                             $(data).each(function(u, value){

                                                                                var rowId = value.id_identitas;

                                                                                var row = '<tr class=\'row\' id='+ value.id_identitas +'>';
                                                                                row += '<td>'+value.tipe_identitas +'</td>';
                                                                                row += '<input type=\'hidden\' id=tipe_identitas_'+ rowId +' name=tipe_identitas['+ rowId +'] value='+ value.tipe_identitas +' />';
                                                                                row += '<td>'+value.no_identitas+'</td>';
                                                                                row += '<input type=\'hidden\' id=no_identitas_'+ rowId +' name=no_identitas['+ rowId +'] value='+ value.no_identitas +' />';
                                                                                row += '<td class=\'lastcolumn\'>';    
                                                                                row +=   '<a  title=\'Uprdate\' rel='+ rowId +' class=\'update\'>';
                                                                                row +=      '<img alt=\'Update\' src=\'/images/icon/update.png\'>';
                                                                                row +=   '</a>'; 
                                                                                row +=   '<a  title=\'Delete\' rel='+ rowId +' class=\'delete\'>';
                                                                                row +=       '<img alt=\'Delete\' src=\'/images/icon/delete.png\'>';
                                                                                row +=    '</a>';
                                                                                row +=  '</td>';
                                                                                row += '</tr>';

                                                                                $('.items tbody').append(row);
                                                                        });
                                                                        }
                                                                });
                                                            }
                                                            ", 
                                                            CClientScript::POS_END);
                                                
                                                
                                                $this->widget('ext.jui.CustomAutoComplete',
                                                    array(
                                                    'name'=>'no_identitas',
                                                    'source'=>$this->createUrl('identitas/autocomplete', array('by'=>'no_identitas')),
                                                    'htmlOptions'=>array('placeholder'=>'No Identitas'),
                                                    'methodChain'=>'.data( "autocomplete" )._renderItem = function( ul, item ) {
                                                        return $( "<li></li>" )
                                                            .data( "item.autocomplete", item )
                                                            .append("<a>"+ item.no_identitas +  "("+ item.tipe_identitas +") <br/><span style=font-size:10px>"+ item.nama_tamu +" ("+item.instansi+")</span></a>")
                                                            .appendTo( ul );
                                                    };',
                                                    'options'=>
                                                        array(
                                                            'mustMatch'=> TRUE,
                                                            'showAnim'=>'fold',
                                                            'select'=>"js:function(hotel, ui) {
                                                                    confirm_tamu(ui);
                                                                    dataTamu = ui;
                                                                }"
                                                                ),
                                                    'cssFile'=>false,
                                                    ));
                                                ?>
                                        </td>
                                </tr>
                                <tr>
                                     <td width="150"><?php echo CHtml::label('Tipe Identitas', 'tipe_identitas')?> : </td>
                                        <td width="500">
                                                <?php 
                                                echo Chtml::textField(
                                                        'tipe_identitas',
                                                        NULL,
                                                        array(
                                                          'placeholder'=>'KTP/SIM/Passport/lainnya'
                                                        )
                                                     );
                                                ?>
                                        </td>

                                </tr>
                                <tr>
                                    <td><input type="button" value="Tambah" id="ad_identitas_btn" class="ax-btn"></td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <?php
                                    
                                    Yii::app()->clientScript->registerScript(
                                            'add_identitas', 
                                            "
                                                var update='';
                                                $('.update').live('click', function(){
                                                    var id = $(this).attr('rel');
                                                    $('#tipe_identitas').val($('#tipe_identitas_'+id).val());
                                                    $('#no_identitas').val($('#no_identitas_'+id).val());
                                                    update = id;
                                                });
                                                
                                                $('.delete').live('click', function(){
                                                    var id = $(this).attr('rel');
                                                    $('.items tbody #'+id).replaceWith('');
                                                });

                                                $('#ad_identitas_btn').click(function(){
                                                    if($('#tipe_identitas').val()=='' || $('#no_identitas').val()==''){
                                                        alert('No/tipe identitas masih kosong')
                                                    }else{
                                                        
                                                        if(update!=''){
                                                            var rowId = update;
                                                        }else{
                                                            var rowId = '';
                                                            $('.items tbody tr').each(function(i, l){
                                                                rowId = parseInt($(this).attr('id'))+1;
                                                            });
                                                            if(rowId=='')
                                                                rowId = parseInt($('.items tbody tr').size())+1;
                                                        }
                                                        
                                                        var row = '<tr class=\'row\' id='+ rowId +'>';
                                                            row += '<td>'+$('#tipe_identitas').val()+'</td>';
                                                            row += '<input type=\'hidden\' id=tipe_identitas_'+ rowId +' name=tipe_identitas['+ rowId +'] value='+ $('#tipe_identitas').val() +' />';
                                                            row += '<td>'+$('#no_identitas').val()+'</td>';
                                                            row += '<input type=\'hidden\' id=no_identitas_'+ rowId +' name=no_identitas['+ rowId +'] value='+ $('#no_identitas').val() +' />';
                                                            row += '<td class=\'lastcolumn\'>';    
                                                            row +=   '<a  title=\'Uprdate\' rel='+ rowId +' class=\'update\'>';
                                                            row +=      '<img alt=\'Update\' src=\'/images/icon/update.png\'>';
                                                            row +=   '</a>'; 
                                                            row +=   '<a  title=\'Delete\' rel='+ rowId +' class=\'delete\'>';
                                                            row +=       '<img alt=\'Delete\' src=\'/images/icon/delete.png\'>';
                                                            row +=    '</a>';
                                                            row +=  '</td>';
                                                            row += '</tr>';
                                                            
                                                            if(update!=''){
                                                                $('.items tbody #'+update).replaceWith(row);
                                                            }else{
                                                                $('.items tbody').append(row);
                                                            }
                                                            update = '';
                                                            $('#tipe_identitas').val(''); 
                                                            $('#no_identitas').val('');
                                                    }
                                                });
                                            ", 
                                            CClientScript::POS_END);
                                    ?>
                                </tr>
                                <tr>
                                        <td colspan="2">
                                                
                                            
                                            <div class="grid-view" id="pegawai-grid">
                                                <div style="height:17px;border:0px;" class="x-panel-header-default x-horizontal x-panel-header-horizontal x-panel-header-default-horizontal x-top x-panel-header-top x-panel-header-default-top x-docked-top x-panel-header-docked-top x-panel-header-default-docked-top x-unselectable">                    
                                                    <span class="x-panel-header-text x-panel-header-text-default">                                            
                                                    </span>
                                                </div>
                                                <div class="ax-body-panel">
                                                    <div style="clear: both;"></div>
                                                    <table class="items" id="identitas_table">
                                                        <thead>
                                                            <tr>
                                                                <th id="pegawai-grid_c1">
                                                                   Tipe Identitas
                                                                </th>
                                                                <th id="pegawai-grid_c2">
                                                                    No Identitas
                                                                </th>
                                                                <th id="pegawai-grid_c6" class="lastcolumn">&nbsp;</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            
                                                        </tbody>
                                                    </table>
                                            </div><div title="/index.php?r=Pegawai" style="display:none" class="keys"><span>1</span><span>2</span><span>3</span><span>4</span><span>5</span></div>
                                            </div>
                                        </td>

                                </tr>
                                </table>
                            </fieldset>
                            
                            <table>
                                <tr>
                                        <td width="150"><?php echo $form->label($Tamu, 'nama');?> : </td>
                                        <td width="150">
                                                <?php 
                                                echo $form->hiddenField($Tamu, 'id_tamu');
                                                $this->widget('ext.jui.CustomAutoComplete',
                                                            array(
                                                            'model'=>$Tamu,
                                                            'attribute'=>'nama',
                                                            'source'=>$this->createUrl('Tamu/autocomplete', array('by'=>'nama')),
                                                            'htmlOptions'=>array('placeholder'=>'Nama Tamu'),
                                                            'methodChain'=>'.data( "autocomplete" )._renderItem = function( ul, item ) {
                                                                return $( "<li></li>" )
                                                                    .data( "item.autocomplete", item )
                                                                    .append("<a>"+ item.nama_tamu +" ("+item.instansi+")</a>")
                                                                    .appendTo( ul );
                                                            };',
                                                            'options'=>
                                                                array(
                                                                    'mustMatch'=> TRUE,
                                                                    'showAnim'=>'fold',
                                                                    'select'=>"js:function(rollback, ui) {
                                                                        confirm_tamu(ui);                                                                     dataTamu = ui;
                                                                        }"
                                                                        ),
                                                            'cssFile'=>false,
                                                            ));

                                                echo $form->error($Tamu, 'nama');

                                                ?>
                                        </td>

                                </tr>
                                
                                <tr>
                                        <td width="150"><?php echo $form->label($Tamu, 'no_hp');?> : </td>
                                        <td width="200">
                                                <?php 
                                                $this->widget('ext.jui.CustomAutoComplete',
                                                            array(
                                                            'model'=>$Tamu,
                                                            'attribute'=>'no_hp',
                                                            'source'=>$this->createUrl('Tamu/autocomplete', array('by'=>'no_hp')),
                                                            'htmlOptions'=>array('placeholder'=>'No. Handphone'),
                                                            'methodChain'=>'.data( "autocomplete" )._renderItem = function( ul, item ) {
                                                                return $( "<li></li>" )
                                                                    .data( "item.autocomplete", item )
                                                                    .append("<a>"+ item.nama_tamu +" ("+item.instansi+")<br/><span style=font-size:10px>" + item.no_hp +  "</span></a>")
                                                                    .appendTo( ul );
                                                            };',
                                                            'options'=>
                                                                array(
                                                                    'mustMatch'=> TRUE,
                                                                    'showAnim'=>'fold',
                                                                    'select'=>"js:function(rollback, ui) {
                                                                        confirm_tamu(ui);                                                                     dataTamu = ui;
                                                                        }"
                                                                        ),
                                                            'cssFile'=>false,
                                                            ));

                                                echo $form->error($Tamu, 'no_hp');
                                                ?>
                                        </td>
                                </tr>
                                <tr>
                                        <td><?php echo $form->label($Tamu, 'instansi');?> : </td>
                                        <td>
                                                <?php 
                                                            $this->widget('zii.widgets.jui.CJuiAutoComplete',
                                                            array(
                                                            'model'=>$Instansi,
                                                            'attribute'=>'nama',
                                                            'source'=>$this->createUrl('Instansi/autocomplete'),
                                                            'htmlOptions'=>array('placeholder'=>'Instansi'),
                                                            'options'=>
                                                                array(
                                                                    'autoFill'=>true,

                                                                    'showAnim'=>'fold',
                                                                    'select'=>"js:function(hotel, ui) {
                                                                        $('#Instansi_id_instansi').val(ui.item.id_instansi);

                                                                        }"
                                                                        ),
                                                            'cssFile'=>false,
                                                            ));
                                                            echo $form->hiddenField($Instansi, 'id_instansi');
                                                            echo $form->error($Instansi, 'nama');


                                                Yii::app()->clientScript->registerScript('script', 
                                                            "
//                                                            $('#Instansi_nama').focus(function(){
//                                                                    if ($(this).autocomplete('widget').is(':visible')) {
//                                                                        return;
//                                                                    }
//                                                                    $(this).autocomplete('search');
//
//                                                                $(this).val('');
//                                                                    $('#Instansi_id_instansi').val('');
//
//                                                            });
//
//                                                            $('#Instansi_nama').focusout(function(){
//                                                                    if($('#Instansi_id_instansi').val()==''){
//
//                                                                            $(this).val('');
//                                                                            $('#Instansi_id_instansi').val('');
//
//                                                                        }
//
//                                                            });

                                                            "
                                                        , CClientScript::POS_END);
                                                            ?>
                                        </td>
                                </tr>
                                <tr>
                                        <td><?php echo $form->label($PenerimaanTamu, 'jumlah_tamu');?> : </td>
                                        <td>
                                                <?php 
                                                echo $form->textField($PenerimaanTamu, 'jumlah_tamu');
                                                echo $form->error($PenerimaanTamu, 'jumlah_tamu');
                                                ?>
                                        </td>
                                </tr>
                                <tr>
                                        <td><?php echo $form->label($PenerimaanTamu, 'kartu_tamu');?> : </td>
                                        <td>
                                                <?php 
                                                echo $form->dropDownList(
                                                        $PenerimaanTamu,
                                                        'id_kartu_tamu', 
                                                        CHtml::listData(
                                                                KartuTamu::model()->findAll(
                                                                        array(
                                                                            'condition'=>'status=1', 
                                                                            'order' => 'no_kartu ASC'
                                                                            )
                                                                        ), 
                                                                'id_kartu_tamu', 
                                                                'no_kartu'
                                                                ), 
                                                        array('empty'=>'-- Pilih Kartu Tamu Yang Tersedia --')) ;
                                                echo $form->error($PenerimaanTamu, 'id_kartu_tamu');
                                                ?>
                                        </td>
                                </tr>
                        </table>
                            
                        </td>
                        <td style="vertical-align: top;">
                              <!-- modal start-->
                              <div id="capture">
                              </div>
                              
                              <div id="camera">
                                            <?php
                                                echo $form->hiddenField($Tamu, 'foto');
                                            
                                                $completionHandler = "
                                                    if (msg != 'ERROR') {
                                                        $('#Tamu_foto').val(msg);
                                                        $('#modal').hide();
                                                        var foto = '<img src=/images/photos/temp/'+msg+' />';
                                                        $('#capture').html(foto);
                                                    }
                                                    else alert('PHP Error: ' + msg);
                                                    ";

                                                $this->widget('application.extensions.jpegcam.EJpegcam', array(
                                                        'apiUrl' => Yii::app()->createUrl('PenerimaanTamu/jpegcam.saveJpg'),
                                                        'shutterSound' => true,
                                                        'jpegQuality' => 100,
                                                        'stealth' => true,
                                                        'buttons' => array(
                                                            //'configure' => 'Configure',
                                                            //'takesnapshot' => 'Snap',
                                                            //'freeze' => 'Capture',
                                                            //'upload' => 'Upload',
                                                            //'reset' => 'Reset'
                                                        ),
                                                        'onBeforeSnap' => '',
                                                        'completionHandler' => $completionHandler
                                                    ));
                                                
                                                ?>
                                        
                              </div>        
                                        
                                        <!-- modal end -->
                                        
                                            
                                        <?php
                                            echo "<br/>";
                                                echo CHtml::button('Snap', array('id'=>'photoSnap', 'onClick'=>'snap()'));
                                                echo CHtml::button('Reset', array('id'=>'photoReset', 'onClick' =>'hideCamera()', 'style'=>'display:none'));
                                                Yii::app()->clientScript->registerScript('script', 
                                                    "
                                                        var isCaptured = 0;
                                                       function snap(){
                                                            isCaptured = 1;
                                                            take_snapshot();
                                                            $('#camera').hide();
                                                            $('#capture').show();
                                                            $('#photoSnap').hide();
                                                            $('#photoReset').show();
                                                       }
                                                       
                                                       function hideCamera(){
                                                            isCaptured = 0;
                                                            webcam.reset()
                                                            $('#camera').show();
                                                            $('#capture').hide();
                                                            $('#photoSnap').show();
                                                            $('#photoReset').hide();
                                                       }
                                                       
                                                         
                                                    "
                                                , CClientScript::POS_BEGIN);
                                        ?>
                        </td>
                    </tr>
                </table>
		
	</fieldset>
	<!-- <fieldset> 
		<legend>Waktu/lokasi</legend>
		<table>
			<tr>
				<td width="150"><?php echo $form->label($PenerimaanTamu, 'jadwal_mulai');?></td>
				<td width="200">
                                   <?php 
                                    $this->widget(
                                                'ext.jui.EJuiDateTimePicker',
                                                array(
                                                    'model'     => $PenerimaanTamu,
                                                    'attribute' => 'jadwal_mulai',
                                                    'language'=> 'en',//default Yii::app()->language
                                                    //'mode'    => 'datetime',//'datetime' or 'time' ('datetime' default)
                                                    'options'   => array(
                                                        'dateFormat' => 'dd-mm-yy',
                                                        'timeFormat' => 'hh:mm tt',//'hh:mm tt' default
                                                    ),
                                                    'htmlOptions'=>array(
                                                        'placeholder'=>'jadwal Mulai'
                                                    )
                                                )
                                            );
                                        
					echo $form->error($PenerimaanTamu, 'jadwal_mulai');
					?>
				</td>
				<td >&nbsp;</td>
				<td width="150"><?php echo $form->label($PenerimaanTamu, 'jadwal_selesai');?></td>
				<td width="200">
					<?php 
					$this->widget(
                                                'ext.jui.EJuiDateTimePicker',
                                                array(
                                                    'model'     => $PenerimaanTamu,
                                                    'attribute' => 'jadwal_selesai',
                                                    'language'=> 'en',//default Yii::app()->language
                                                    //'mode'    => 'datetime',//'datetime' or 'time' ('datetime' default)
                                                    'options'   => array(
                                                        'dateFormat' => 'dd-mm-yy',
                                                        'timeFormat' => 'hh:mm tt',//'hh:mm tt' default
                                                    ),
                                                    'htmlOptions'=>array(
                                                        'placeholder'=>'jadwal Mulai'
                                                    )
                                                )
                                            );
					echo $form->error($PenerimaanTamu, 'jadwal_selesai');
					?>
				</td>
				<td rowspan="1" width="500">
				</td>
			</tr>
			<tr>
				<td width="150"><?php echo $form->label($Meetingroom, 'nama_ruang');?></td>
				<td width="200">
					<?php 
                                        $this->widget('zii.widgets.jui.CJuiAutoComplete',
                                        array(
                                        'model' => $Meetingroom,
                                        'attribute' => 'nama',
                                        'source' => $this->createUrl('Meetingroom/autocomplete'),
                                        'htmlOptions' => array('placeholder'=>'Nama Ruang'),
                                        'options'=>
                                            array(
                                                'showAnim'=>'fold',
                                                'select'=>"js:function(hotel, ui) {
                                                    $('#Meetingroom_id_meetingroom').val(ui.item.id);
                                                    $('#Meetingroom_kapasitas').val(ui.item.kapasitas);
                                                    $('#Meetingroom_lokasi').val(ui.item.lokasi);
                                                    }"
                                                    ),
                                        'cssFile'=>false,
                                        ));
                                        echo $form->hiddenField($Meetingroom, 'id_meetingroom');
					echo $form->error($Meetingroom, 'nama');
					?>
				</td>
				<td >&nbsp;</td>
				<td width="150"><?php echo $form->label($Meetingroom, 'lokasi');?></td>
				<td width="200">
					<?php 
					echo $form->textField($Meetingroom, 'lokasi', 
                                                array(
                                                    'placeholder' => 'lokasi',
                                                    'readonly' => 'readonly'
                                                    )
                                                );
					echo $form->error($PenerimaanTamu, 'lokasi');
					?>
				</td>
			</tr>
			<tr>
				<td width="150"><?php echo $form->label($Meetingroom, 'kapasitas');?></td>
				<td width="200">
					<?php 
					echo $form->textField($Meetingroom, 'kapasitas',
                                                array(
                                                    'placeholder' => 'lokasi',
                                                    'readonly' => 'readonly'
                                                    )
                                                );
					echo $form->error($PenerimaanTamu, 'kapasitas');
					?>
				</td>
				<td colspan="3">&nbsp;</td>
			</tr>
		</table>
	</fieldset> -->
    
        <table>
            <tr>
                <td>
                    <fieldset>
                            <legend>Tujuan</legend>
                            <table>
                                    <tr>
                                            <td width="150"><?php echo $form->label($Pegawai, 'nama : ');?> </td>
                                            <td width="200">
                                                    <?php 
                                                    $this->widget('ext.jui.CustomAutoComplete',
                                                    array(
                                                    'model'=>$Pegawai,
                                                    'attribute'=>'nama',
                                                    'source'=>$this->createUrl('Pegawai/autocomplete'),
                                                    'htmlOptions'=>array('placeholder'=>'Nama Personal tujuan'),
                                                    'methodChain'=>'.data( "autocomplete" )._renderItem = function( ul, item ) {
                                                        return $( "<li></li>" )
                                                            .data( "item.autocomplete", item )
                                                            .append( "<a>" + item.label +  "<br/><span style=font-size:10px>"+ item.jabatan +"</span></a>" )
                                                            .appendTo( ul );
                                                    };',
                                                    'options'=>
                                                        array(
                                                            'mustMatch'=> TRUE,
                                                            'showAnim'=>'fold',
                                                            'select'=>"js:function(hotel, ui) {
                                                                $('#PenerimaanTamu_id_pegawai').val(ui.item.id_pegawai);
                                                                $('#Pegawai_nip').val(ui.item.nip);
                                                                $('#Jabatan_nama').val(ui.item.jabatan);
                                                                $('#Jabatan_id_jabatan').val(ui.item.id_jabatan);
                                                                $('#unit').val(ui.item.struktur_organisasi);
                                                                }"
                                                                ),
                                                    'cssFile'=>false,
                                                    ));
                                                    echo $form->hiddenField($PenerimaanTamu, 'id_pegawai');
                                                    echo $form->error($PenerimaanTamu, 'id_pegawai');
                                                    ?>
                                            </td>
                                            <td >&nbsp;</td>
                                            <td width="150"><?php echo $form->label($Pegawai, 'nip : ');?></td>
                                            <td width="200">
                                                    <?php 
                                                    echo $form->textField($Pegawai, 'nip', array('readonly'=>'readonly'));
                                                    echo $form->error($Pegawai, 'nip');
                                                    ?>
                                            </td>
                                           
                                    </tr>
                                    <tr>
                                            <td width="150"><?php echo $form->label($Jabatan, 'Jabatan : ');?> </td>
                                            <td width="200">
                                                    <?php 
                                                    echo $form->hiddenField($Jabatan, 'id_jabatan');
                                                    echo $form->textField($Jabatan, 'nama', array('readonly'=>'readonly'));
                                                    echo $form->error($Jabatan, 'nama');
                                                    ?>
                                            </td>
                                            <td>&nbsp;</td>
                                            <td><label>Unit : </label></td>
                                            <td> <?php 
                                                    echo CHtml::textField('unit', null, array('readonly'=>'readonly'));
                                                    ?></td>
                                    </tr>
                            </table>
                    </fieldset>
                </td>
                <td width="50%">
                    <fieldset>
                            <legend>Keperluan</legend>
                             <table width="50%">
                                    <tr>
                                            <td width="150"><?php echo $form->label($JenisKeperluan, 'Keperluan : ');?> </td>
                                            <td width="200">
                                                    <?php 
                                                    $this->widget('zii.widgets.jui.CJuiAutoComplete',
                                                    array(
                                                    'model'=>$JenisKeperluan,
                                                    'attribute'=>'nama',
                                                    'source'=>$this->createUrl('JenisKeperluan/autocomplete'),
                                                    'htmlOptions'=>array('placeholder'=>'Keperluan'),
                                                    'options'=>
                                                        array(
                                                            'showAnim'=>'fold',
                                                            'select'=>"js:function(hotel, ui) {
                                                                $('#JenisKeperluan_id_keperluan').val(ui.item.id);
                                                                
                                                                }"
                                                                ),
                                                    'cssFile'=>false,
                                                    ));
                                                    echo $form->hiddenField($JenisKeperluan, 'id_keperluan');
                                                    echo $form->error($JenisKeperluan, 'nama');
                                                    ?>
                                            </td>
                                            
                                    </tr>
                                    
                            </table>
                    </fieldset>
                </td>
            </tr>
        </table>
	
	
        <?php 
		echo CHtml::submitButton('Save', array('class'=>'ax-btn')); 
	$this->endWidget(); 
	?>
</div>

<?php $this->endWidget();?>
<!-- form end -->
<?php //echo $this->renderPartial('_form', array('PenerimaanTamu'=>$PenerimaanTamu)); ?>
